package com.baizhi.domain;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

// 建立实体类和Collection的关系
@Document("article")
public class Article {

    // 用来标识主键
    @Id
    private Integer id;

    // 建立实体类中属性和Collection中字段映射关系
    // 如果省略，代表两个名称一致
    @Field("title")
    private String title;

    private String context;

    private Integer hits;

    public Article() {
    }

    public Article(String title, String context, Integer hits) {
        this.title = title;
        this.context = context;
        this.hits = hits;
    }

    public Article(Integer id, String title, String context, Integer hits) {
        this.id = id;
        this.title = title;
        this.context = context;
        this.hits = hits;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContext() {
        return context;
    }

    public void setContext(String context) {
        this.context = context;
    }

    public Integer getHits() {
        return hits;
    }

    public void setHits(Integer hits) {
        this.hits = hits;
    }

    @Override
    public String toString() {
        return "Article{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", context='" + context + '\'' +
                ", hits=" + hits +
                '}';
    }
}
